class: center, middle, inverse, title-slide .title[ # Package your Knowledge! ] .subtitle[ ## Mainstream documentation and test with {fusen} ] .date[ ### Training Content as of 06 November 2023 ] --- --- ## Introduction * Why creating packages? We will explore how to transition from functions to packages, the added value of using packages, and why documentation is crucial. --- ## Why Create Packages? Code Organization Packages help you organize your code. Group related functions and data into a single unit. Code Reusability Share your work with others or your future self. Functions and datasets are easily accessible. Collaboration Share your packages with the R community. Contribute to the R ecosystem. --- ## From a collection of Function to a Package Create a directory with a package structure. Place your functions and data in the package. Add package documentation. Use `devtools` to build and install the package. --- ## Key Differences Packages are a collection of functions, data, and documentation. A package can be easily shared and used across different projects. --- ## Package Directory Structure ``` MyPackage/ |-- R/ | |-- my_function.R | |-- man/ | |-- my_function.Rd | |-- DESCRIPTION |-- NAMESPACE |-- README.md ``` --- ## Steps to Create a Package Use devtools or usethis to create a package structure. Write your functions and add them to the R directory. Document your functions using roxygen2. Build the package using devtools::document() and devtools::install(). Your package is now ready for use and sharing. --- ## Documentation Is Essential Why Document Packages? Documentation provides information on how to use a package. Helps users understand the purpose and usage of functions. Makes your package user-friendly. R Documentation Use roxygen2 for generating package documentation. Add details about functions, data, and examples. --- ## Managing release Alpha Version: Alpha versions are the earliest stages of software development. They are typically not feature-complete and may contain many bugs and incomplete features. Alpha versions are often used for internal testing and may not be released to the public. Developers use alpha versions to identify and fix major issues. Beta Version: Beta versions come after alpha versions in the development cycle. They are more stable than alpha versions but may still contain bugs and issues. Beta versions are often released to a select group of users for testing, known as beta testers. Beta testing helps identify issues and gather user feedback before the final release. Release Candidate (RC): A release candidate is a version of the software that is considered stable and feature-complete. RC versions are released to a wider audience for testing to ensure there are no major issues. If no critical bugs are found in the release candidate, it may become the final release. --- ## Conclusion Creating packages in R is essential for code organization and sharing. Transition from standalone functions to packages for better code management. Proper documentation is crucial for effective collaboration and code sharing. --- ## Thank You Thank you for your attention! Questions?